/**
 *
 */
package com.angel.mocks.data.generator.dataGenerator;

import java.util.Collection;
import java.util.List;

import com.angel.dao.generic.factory.DAOFactory;
import com.angel.dao.generic.interfaces.GenericDAO;
import com.angel.data.generator.interfaces.DataGenerator;
import com.angel.data.generator.interfaces.impl.FileDataGenerator;
import com.angel.mocks.data.generator.daos.impl.AddressHibernateDAO;
import com.angel.mocks.data.generator.domainObject.Address;

/**
 * @author William
 *
 */
public class AddressFileDataGenerator extends FileDataGenerator{

	private static final long serialVersionUID = -6660041377354830324L;

	public AddressFileDataGenerator(){
		super("/target/test-classes/address.txt");
	}

	public void generateData(Collection<Object> dataCollection, DAOFactory daoFactory, List<String[]> rows) {
		for(String[] row : rows){
			if(row != null && row.length == 3){
				Address address = new Address();
				address.setCity(row[0]);
				address.setName(row[1]);
				address.setNumber(Integer.valueOf(row[2].trim()));
				dataCollection.add(address);
			}
		}
	}

	@SuppressWarnings("unchecked")
	public Class<? extends DataGenerator>[] getDependecesGenerators() {
		return (Class<? extends DataGenerator>[]) new Class<?>[]{};
	}

	@SuppressWarnings("unchecked")
	public GenericDAO getGenericDAO() {
		return new AddressHibernateDAO();
	}

	public Class<? extends Object> getDataGeneratorClass() {
		return Address.class;
	}

	public Class<?> thisDataGeneratorClass() {
		return this.getClass();
	}
}
